package pers.mihao.quickstream.common.plus.wrapper;

import java.lang.reflect.Constructor;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * @author mihao
 * @since 2022/8/1
 */
public class WrapperCreateInfo implements Comparable<WrapperCreateInfo> {
    Constructor<?> constructor;
    Integer order;
    Set<String> wrappedSet;
    Class<?> wrapperClass;

    public WrapperCreateInfo(Class<?> clazz, Constructor<?> constructor, Integer order) {
        this.constructor = constructor;
        this.order = order;
        wrappedSet = new HashSet<>();
        wrapperClass = clazz;
    }

    public Integer getOrder() {
        return order == null ? 0 : order;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        WrapperCreateInfo that = (WrapperCreateInfo) o;
        return Objects.equals(constructor, that.constructor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(constructor);
    }

    @Override
    public int compareTo(WrapperCreateInfo o) {
        return Integer.compare(getOrder(), o.getOrder());
    }
}
